<?php

/**
 * This is the model class for table "tbl_emailsettings".
 *
 * The followings are the available columns in table 'tbl_emailsettings':
 * @property integer $id
 * @property string $smtpserver
 * @property string $smtploginuser
 * @property string $smtppassword
 * @property string $smtpport
 * @property string $loginmethod
 * @property integer $ssl
 * @property integer $starttls
 * @property string $invoiceemaildisplayname
 * @property string $invoicereturnemail
 * @property string $poemaildisplayname
 * @property string $poreturnemail
 * @property integer $sendcopy
 */
class Emailsettings extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Emailsettings the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_emailsettings';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ssl, starttls, sendcopy', 'numerical', 'integerOnly'=>true),
			array('smtpserver, smtploginuser, smtppassword', 'length', 'max'=>80),
			array('smtpport', 'length', 'max'=>20),
			array('loginmethod', 'length', 'max'=>50),
			array('invoiceemaildisplayname, invoicereturnemail, poemaildisplayname, poreturnemail', 'length', 'max'=>150),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, smtpserver, smtploginuser, smtppassword, smtpport, loginmethod, ssl, starttls, invoiceemaildisplayname, invoicereturnemail, poemaildisplayname, poreturnemail, sendcopy', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'smtpserver' => 'SMTP Server',
			'smtploginuser' => 'SMTP Login User',
			'smtppassword' => 'SMTP Password',
			'smtpport' => 'SMTP Port',
			'loginmethod' => 'Login Method',
			'ssl' => 'USE SSL',
			'starttls' => 'Use STARTTLS',
			'invoiceemaildisplayname' => 'Email Display Name',
			'invoicereturnemail' => 'Return Email Address',
			'poemaildisplayname' => 'Email Display Name',
			'poreturnemail' => 'Return Email Address',
			'sendcopy' => 'Send Copy to Return Email Address',
		);
	}
	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('smtpserver',$this->smtpserver,true);
		$criteria->compare('smtploginuser',$this->smtploginuser,true);
		$criteria->compare('smtppassword',$this->smtppassword,true);
		$criteria->compare('smtpport',$this->smtpport,true);
		$criteria->compare('loginmethod',$this->loginmethod,true);
		$criteria->compare('ssl',$this->ssl);
		$criteria->compare('starttls',$this->starttls);
		$criteria->compare('invoiceemaildisplayname',$this->invoiceemaildisplayname,true);
		$criteria->compare('invoicereturnemail',$this->invoicereturnemail,true);
		$criteria->compare('poemaildisplayname',$this->poemaildisplayname,true);
		$criteria->compare('poreturnemail',$this->poreturnemail,true);
		$criteria->compare('sendcopy',$this->sendcopy);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}